<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>综合充值卡模板管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
				rules:{
	                "retail_price": "ifMoney",
	                "product_discount": {
	                 	"range":[1,100] 
	                 },
	                 "care_discount": {
	                 	"range":[1,100] 
	                 }
	            },
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			$("#retail_price").change(function(){
				$("#real_cost").val($(this).val());
			});
			addParentPageNo();
		});
		
		function addParentPageNo() {
			var id = '${storeCardTemplateAll.id}';
			var pageNo = 1;
			if(id != "" && sessionStorage.parentPageNo) {
				pageNo = sessionStorage.parentPageNo;
			}
			$("#pageNo").val(pageNo);
			var href = "${ctx}/base/storeCardTemplateAll/?pageNo=" +pageNo + "&currentSelectId=" +id;
			$("#return").attr("href", href);
		}
	</script>
</head>
<body>
	<form:form id="inputForm" class="form-input" modelAttribute="storeCardTemplateAll" action="${ctx}/base/storeCardTemplateAll/save" method="post" >
		<form:hidden path="id"/>
		<input type="hidden" id="pageNo" name="pageNo" />
		<div class="icon-buttons">
			<a id="return" data-role="button" data-inline="true" data-icon="back" data-iconpos="notext"  href="">返回</a>
			<input type="submit" value="保 存" data-icon="check" data-iconpos="notext"  data-inline="true"/>
		</div>
		<tags:message content="${message}"/>
		<div data-role="fieldcontain">
			<label for="name">名称:</label>
			<form:input path="name" htmlEscape="false" maxlength="11" class="required"/>
		</div>
		<div data-role="fieldcontain">
			<label for="retail_price">零售价（元）:</label>
			<form:input path="retail_price" htmlEscape="false" maxlength="50" class="required"/>
		</div>
		<div data-role="fieldcontain">
			<label for="product_discount">购买产品折扣（%）:</label>
			<input type="text" id="product_discount" value="${fns:changeDisCount(storeCardTemplateAll.product_discount)}" name="product_discount" class="required digits"/>
		</div>
		<div data-role="fieldcontain">
			<label for="care_discount">购买护理项目折扣（%）:</label>
			<input type="text" id="care_discount" value="${fns:changeDisCount(storeCardTemplateAll.care_discount)}" name="care_discount" class="required digits"/>
		</div>
		<div data-role="fieldcontain">
			<label for="real_cost">开卡优惠价（元）:</label>
			<form:input path="real_cost" htmlEscape="false" maxlength="50" class="required"/>
		</div>
	</form:form>
</body>
</html>
